import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
import axios from 'axios'

import echarts from 'echarts'
import Pubsub from 'pubsub-js'

Vue.prototype.$echarts = echarts
Vue.prototype.$Pubsub = Pubsub
axios.defaults.withCredentials = true

// 设置全局的
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
let instance = axios.create({}) // 这样创建出来的 只需要：
instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
// 配置请求的根路径
axios.defaults.baseURL = 'http://192.168.137.1:8080/unnamed/'
Vue.prototype.$http = axios

// 通过axios请求拦截器添加token,保证拥有获取数据的权限
// axios拦截
axios.interceptors.request.use(config => {
  // 为请求头对象，添加Token验证的 Authorization 字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
